package com.nancy.java_design.simple_factory;

import com.nancy.java_design.simple_factory.demo2.Coffee;
import com.nancy.java_design.simple_factory.demo2.SimpleCoffeeFactory;

/**
 * 咖啡
 */
public class CoffeeStore {


//    // 获取咖啡
//    public static Coffee orderCoffee(String type) {
//        Coffee coffee;
//        if (type.equalsIgnoreCase("American")) {
//            coffee = new AmericanCoffee();
//        } else if (type.equalsIgnoreCase("Lattle")) {
//            coffee = new LattleCoffee();
//        } else {
//            throw new RuntimeException("没有该种咖啡");
//        }
//
//        coffee.addMilk();
//        coffee.addSugur();
//        coffee.getName();
//
//        return coffee;
//    }
//
//    public static void main(String[] args) {
//        orderCoffee("American");
//        orderCoffee("Lattle");
//    }

    // 咖啡店不再需要知道具体的咖啡种类，只需要知道咖啡的类型就可以了，通过简单工厂来获取，完成了解耦
    public static void main(String[] args) {
        SimpleCoffeeFactory simpleCoffeeFactory = new SimpleCoffeeFactory();
        Coffee coffee = simpleCoffeeFactory.orderCoffee("American");
    }
}
